package com.example.rbac.controller;

import com.example.rbac.beans.PageQuery;
import com.example.rbac.common.web.JsonData;
import com.example.rbac.param.SearchLogParam;
import com.example.rbac.service.SysLogService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;

/**
 * @author XieLongzhen
 * @date 2019/2/21 18:59
 */
@Controller
@RequestMapping("/sys/log")
public class SysLogController {

    @Resource
    private SysLogService sysLogService;

    @GetMapping("/log.page")
    public ModelAndView page() {
        return new ModelAndView("log");
    }

    @GetMapping("/recover.json")
    @ResponseBody
    public JsonData searchPage(@RequestParam("id") int id) {
        sysLogService.recover(id);
        return JsonData.success();
    }

    @PostMapping("/page.json")
    @ResponseBody
    public JsonData searchPage(SearchLogParam param, PageQuery page) {
        return JsonData.success(sysLogService.searchPageList(param, page));
    }
}
